package com.dd.cloud.gateway.exception;

import com.dd.cloud.common.enums.ExceptionEnumInterface;
import com.dd.cloud.common.vo.EnumResultVo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 接口异常枚举封装
 *
 * @author zk
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum GatewayExceptionEnum implements ExceptionEnumInterface {
    ACCOUNT_NOT_FOUND(403, "请重新登录"),
    LOGIN_PARSING_ERROR(403, "身份解析失败，请重新登录"),
    SYS_GATEWAY_ERROR_NACOS(503," 服务没有注册到nacos上"),
    NO_ERMSSION(400, "你没有这个权限");



    private int code;
    private String msg;

    @Override
    public EnumResultVo getMessage() {
        GatewayExceptionEnum gatewayExceptionEnum = GatewayExceptionEnum.valueOf(this.name());
        return new EnumResultVo(gatewayExceptionEnum.code, gatewayExceptionEnum.msg);
    }

    @Override
    public String setMessage(String msg) {
        GatewayExceptionEnum gatewayExceptionEnum = GatewayExceptionEnum.valueOf(this.name());
        return String.format(gatewayExceptionEnum.getMsg(), msg);
    }
}
